package com.woniu.new_orange.send_email;


import com.woniu.new_orange.util.Result;
import com.woniu.new_orange.util.Email;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;

@RestController
@RequestMapping("/sendEmail")
public class SendEmail {

    @Autowired
    private Email email;

    @PostMapping("")
    public Result sendEmail(@RequestBody EmailDto userEmail){
        String title = "确认合同信息";
        String content = "尊敬的用户，您好：恭喜您在我平台申请贷款的流程已审批通过，审批详情可查看合同模版，确认无误后，请自行打印合同并邮寄到我司位置^_^";
        File file = new File("/Users/donghang/Downloads/001.docx");
        email.sendMessageCarryFile(userEmail.getUserEmail(),title,content,file);
        return Result.ok();
    }
    @PostMapping("/emailFailed")
    public Result sendEmailFailed(@RequestBody EmailDto userEmail){
        String title = "审批信息";
        String content = "尊敬的用户，您好：您的审批失败具体请看详情";
        File file = new File("/Users/donghang/Downloads/001.docx");
        email.sendMessageCarryFile(userEmail.getUserEmail(),title,content,file);
        return Result.ok();
    }

    @PostMapping("/cuiShou")
    public Result sendCuishou(@RequestBody EmailDto userEmail){
        String title = "确认合同信息";
        String content = "尊敬的用户，您好：您在我公司贷款的产品即将到达还款日期，请注意还款日期及时还款^_^";
        email.sendMessage(userEmail.getUserEmail(),title,content);
        return Result.ok();
    }
}
